/*
 * SDLPaddle.cpp
 *
 *  Created on: Nov 18, 2010
 *      Author: timmeh
 */

#define res SDLResource::Instance()

#include "SDLPaddle.h"
#include "Vector2.h"
#include <iostream>

namespace bo_sdl {

SDLPaddle::SDLPaddle() {
}

SDLPaddle::~SDLPaddle() {
}
/**
 * Converts the virtual screen position to the real one and blits the surface on the screen
 */
void SDLPaddle::Visualize(){
	Vector2 newPos = Paddle::GetPos().ConvToScreenCoords(res->GetScale()) - this->GetRadius()*res->GetScale();
	res->BlitToScreen(fSprite, newPos);
	//res->FlipScreen();
	//res->ClearBackBuffer();
}

/**
 * Loads the sprite of the paddle, and calculates its virtual radius
 */
void SDLPaddle::SetSprite(const char* fileName, const double scale){
	SDL_Surface* img = IMG_Load(fileName);
	this->fSprite = img;
	Paddle::SetRadius((img->w/2)/scale);
}

}
